import xlwt

# 创建book,并设定编码
workbook = xlwt.Workbook(encoding='ascii')
#创建新的sheet表
worksheet = workbook.add_sheet('new sheet')
# 边框对象
borders = xlwt.Borders()
# 设置边框
borders.left = xlwt.Borders.DOUBLE
borders.right = xlwt.Borders.DOUBLE
borders.top = xlwt.Borders.DOUBLE
borders.bottom = xlwt.Borders.DOUBLE
# 设置边框颜色
borders.left_colour = 0 # 黑色
borders.right_colour = 1 # 白色
borders.top_colour = 2 # 红色
borders.bottom_colour = 3 # 绿色

style = xlwt.XFStyle()
style.borders = borders
# 向单元格中写入内容
worksheet.write(0,0,'hello',style)
workbook.save('test6.xls')


